import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author MyPC
 * @date 2018/7/4
 */

public class JavaSocket {


    /**
     *模拟A对B发送数据
     *
     */
    public static void main(String[] args) throws UnknownHostException {
        //获取本机的InetAddress实例
        InetAddress address =InetAddress.getLocalHost();
        System.out.println(address.getHostName());
        System.out.println(address.getHostAddress());
        byte[] bytes = address.getAddress();//获取字节数组形式的IP地址,以点分隔的四部分

//获取其他主机的InetAddress实例

        InetAddress address3 =InetAddress.getByName("10.5.2.111");
        System.out.println(address3.getAddress());
        System.out.println(address3.getHostName());
    }
}
